 import junit.framework.*;
 import java.util.ArrayList;
 import sonet.*;
 
 
 public class CreateAgentTest extends TestCase{
		
	public void testIndividual(){	
		int id1 = 1;
		int id2 = 2;
		String name = "i1-name";
		String phone = "i1-phone";
		String email = "i1-email";
		Individual i1 = new Individual(id1,name,email,phone);
		Assert.assertEquals( id1, i1.getIdentifier());
		Assert.assertEquals( name, i1.getName());
		Assert.assertEquals( phone, i1.getPhone());
		Assert.assertEquals( email, i1.getEmail());
		Assert.assertEquals( AgentType.INDIVIDUAL, i1.getType());
		Assert.assertEquals( AgentType.INDIVIDUAL, i1.getType());
		Assert.assertEquals( AgentStatus.ACTIVE, i1.getAgentStatus());
		Assert.assertEquals( AgentStatus.ACTIVE, i1.getAgentStatus());
		Assert.assertEquals( AgentStatus.ACTIVE, i1.getAgentStatus());
		Assert.assertEquals( AgentStatus.ACTIVE, i1.getAgentStatus());
		Assert.assertEquals( 0 , i1.getPublications().size());
		Assert.assertEquals( 0 , i1.getInbox().size());
		Assert.assertEquals( 0 , i1.getOutbox().size());
		Assert.assertEquals( 0 , i1.getConnections().size());
		
		Organization o1 = new Organization(id1,name,email,phone);
		Individual i2 = new Individual(id1,name,email,phone);
		Individual i3 = new Individual(id2,name,email,phone);
		
		Assert.assertEquals( i1, i2);
		Assert.assertFalse( i1.equals(i3));
		Assert.assertFalse( i1.equals(o1));
		Assert.assertFalse( i1.equals(null));		
	}
	
	public void testOrganization(){
		int id1 = 1;
		int id2 = 2;
		String name = "i1-name";
		String phone = "i1-phone";
		String email = "i1-email";
		Organization i1 = new Organization(id1,name,email,phone);
		Assert.assertEquals( id1, i1.getIdentifier());
		Assert.assertEquals( name, i1.getName());
		Assert.assertEquals( phone, i1.getPhone());
		Assert.assertEquals( email, i1.getEmail());
		Assert.assertEquals( AgentType.ORGANIZATION, i1.getType());
		Assert.assertEquals( AgentType.ORGANIZATION, i1.getType());
		Assert.assertEquals( AgentStatus.ACTIVE, i1.getAgentStatus());
		Assert.assertEquals( AgentStatus.ACTIVE, i1.getAgentStatus());
		Assert.assertEquals( AgentStatus.ACTIVE, i1.getAgentStatus());
		Assert.assertEquals( AgentStatus.ACTIVE, i1.getAgentStatus());
		Assert.assertEquals( 0 , i1.getPublications().size());
		Assert.assertEquals( 0 , i1.getInbox().size());
		Assert.assertEquals( 0 , i1.getOutbox().size());
		Assert.assertEquals( 0 , i1.getConnections().size());
		
		Individual o1 = new Individual(id1,name,email,phone);
		Organization i2 = new Organization(id1,name,email,phone);
		Organization i3 = new Organization(id2,name,email,phone);
		
		Assert.assertEquals( i1, i2);
		Assert.assertFalse( i1.equals(o1));
		Assert.assertFalse( i1.equals(null));
	}
	
	public void testSocialNetwork(){
		int iId = 1;
		int oId = 2;
		String name = "name";
		String phone = "phone";
		String email = "email";
		Individual i = new Individual(iId,name,phone,email);
		Organization o = new Organization(oId,name,phone,email);
		SocialNetwork sonet = new SocialNetwork();
		
		sonet.addAgent(i);
		sonet.addAgent(o);
		
		Agent a1 = sonet.getAgent(iId);
		Agent a2 = sonet.getAgent(oId);
		
		//test if its same object
		Assert.assertTrue( i == a1); 	
		//test if its same object		
		Assert.assertTrue( o == a2); 
	}
	
	public static void main(String[] args){
		
	}
	
}